I have an issue:
//this console log displays correct value
console.log('localstorage', localStorage.getItem('subMenu'));
setSubMenu(
JSON.parse(localStorage.getItem('subMenu') || JSON.stringify(subMenu))
);
/*
this one displays JSON.stringify(subMenu) value, when
localStorage.getItem('subMenu') is defined
*/
console.log('subMenu', subMenu);
I have no idea what's happening. there is value in localstorage (checked with console logs), but somehow JSON.parse is reading second value.
|| is or operator ... if the result is those bellow,references the one on the right
for example
let a=null || 45; //a=45
let b=12 || 45; //a=12